550D - Regular Bridge - CodeForces Solution


constructive algorithms graphs implementation *1900

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	// freopen("wormhole.in","r",stdin);
	// freopen("wormhole.out","w",stdout);

	int k; cin >> k;

	if(k%2==0){
		cout << "NO\n";
		return 0;
	}

	cout << "YES\n";
	if(k==1){
		cout << 2 << " " << 1 << "\n";
		cout << 1 << " " << 2 << "\n";
		return 0;
	}

	cout << 2*k+4 << " " << (2*k+4)*k/2 << "\n";

	cout << 1 << " " << k+3 << "\n";
	for(int i=1;i<=k+1;i++){
		for(int j=i+1;j<=k+1;j++){
			if(i%2==1 && j==i+1) continue;

			cout << i << " " << j << "\n";
		}
	}

	for(int i=2;i<=k+1;i++) cout << i << " " << k+2 << "\n";

	for(int i=k+3;i<=2*k+3;i++){
		for(int j=i+1;j<=2*k+3;j++){
			if(i%2==0 && j==i+1) continue;

			cout << i << " " << j << "\n";
		}
	}

	for(int i=k+4;i<2*k+4;i++) cout << i << " " << 2*k+4 << "\n";
	return 0;
}


Comments

Submit
0 Comments
More Questions

901A - Hashing Trees
1283A - Minutes Before the New Year
1654D - Potion Brewing Class
1107B - Digital root
25A - IQ test
785A - Anton and Polyhedrons
1542B - Plus and Multiply
306A - Candies
1651C - Fault-tolerant Network
870A - Search for Pretty Integers
1174A - Ehab Fails to Be Thanos
1169A - Circle Metro
780C - Andryusha and Colored Balloons
1153A - Serval and Bus
1487C - Minimum Ties
1136A - Nastya Is Reading a Book
1353B - Two Arrays And Swaps
1490E - Accidental Victory
1335A - Candies and Two Sisters
96B - Lucky Numbers (easy)
1151B - Dima and a Bad XOR
1435B - A New Technique
1633A - Div 7
268A - Games
1062B - Math
1294C - Product of Three Numbers
749A - Bachgold Problem
1486B - Eastern Exhibition
1363A - Odd Selection
131B - Opposites Attract